<template>
  <div :id="id" class="chart-base"></div>
</template>

<script>
import mixin from "./mixin";
import * as echarts from "echarts";
export default {
  name: "ChartGauge",
  mixins: [mixin],
  data: () => {
    return {
      id: null,
      chart: null,
      dom: null,
      option: {
        series: [
          {
            type: "gauge",
            startAngle: 90,
            endAngle: -270,
            pointer: {
              show: false
            },
            progress: {
              show: true,
              overlap: false,
              roundCap: true,
              clip: false,
              itemStyle: {
                borderWidth: 1,
                borderColor: "#464646"
              }
            },
            axisLine: {
              lineStyle: {
                width: 6
              }
            },
            splitLine: {
              show: false,
              distance: 0,
              length: 10
            },
            axisTick: {
              show: false
            },
            axisLabel: {
              show: false,
              distance: 50
            },
            data: [],
            title: {
              fontSize: 14
            },
            detail: {
              width: 50,
              height: 14,
              fontSize: 14,
              color: "auto",
              borderColor: "auto",
              borderRadius: 20,
              borderWidth: 1,
              formatter: "{value}%"
            }
          }
        ]
      }
    };
  },
  methods: {
    created(option) {
      this.option.series[0].data = option;
      this.dom = document.getElementById(this.id);
      this.chart = echarts.init(this.dom);
      this.option && this.chart.setOption(this.option);
    }
  }
};
</script>

<style scoped>
.chart-base {
  width: 100%;
  height: 100%;
}
</style>
